package com.stu.status;

import java.util.ArrayList;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.stu.aq.*;
import com.stu.widget.*;

public class SystemStatusFragment extends Fragment {
	
	private class StatusIndex {
		public final static int ROLL = 0;
		public final static int PITCH = 1;
		public final static int HEADING = 2;
		public final static int ALTITUDE = 3;
		public final static int BATTERY = 4;
	}
	private ArrayList<TextValueView> widgets;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	  Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.system_status, container, false);
		widgets = new ArrayList<TextValueView>();
		widgets.add( (TextValueView)v.findViewById(R.id.roll_value) );
		widgets.add( (TextValueView)v.findViewById(R.id.pitch_value) );
		widgets.add( (TextValueView)v.findViewById(R.id.heading_value) );
		widgets.add( (TextValueView)v.findViewById(R.id.altitude_value) );
		widgets.add( (TextValueView)v.findViewById(R.id.battery_value) );
		return v;
	}
	
	public void setRollValue( String v ) {
		widgets.get( StatusIndex.ROLL ).setText( v );
	}
	
	public void setPitchValue( String v ) {
		widgets.get( StatusIndex.PITCH ).setText( v );
	}
	
	public void setHeadingValue( String v ) {
		widgets.get( StatusIndex.HEADING ).setText( v );
	}
	
	public void setAltitudeValue( String v ) {
		widgets.get( StatusIndex.ALTITUDE ).setText( v );
	}
	
	public void setBatteryValue( String v ) {
		widgets.get( StatusIndex.BATTERY ).setText( v );
	}
	
	public void clear() {
		for( TextValueView t : widgets )
			t.setText( "" );
	}
}
